package com.init.system.dingding;

import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiMediaUploadRequest;
import com.dingtalk.api.response.OapiMediaUploadResponse;
import com.taobao.api.ApiException;
import com.taobao.api.FileItem;

/**
 * 上传图片到钉钉服务器上
 */
public class Main {
    public static void main(String[] args) {
        try {
            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/media/upload");
			OapiMediaUploadRequest req = new OapiMediaUploadRequest();
			req.setType("image");
			req.setMedia(new FileItem("D:\\资料文件目录\\壁纸\\11.jpeg"));
            // c368086df0773bb98d9de34ad5d04ca7 =token
			OapiMediaUploadResponse rsp = client.execute(req, "c368086df0773bb98d9de34ad5d04ca7");
			System.out.println(rsp.getBody());
        } catch (ApiException e) {
            e.printStackTrace();
        }
    }
}